package com.jk.dao.login;

import com.jk.pojo.PayBank;
import com.jk.pojo.PayUser;
import org.apache.ibatis.annotations.*;

/**
 * &lt;pre&gt;项目名称：jk-pay
 * 类名称：
 * 创建人：李金春
 * 手机号：18839726119
 * 创建时间：
 * 修改人：李金春
 * 修改时间：
 * 修改备注：修改用户登录业务（邮箱登录、账号登录、新增修改登录时间）  --李金春--2018-1-2 14:03:50
 */
public interface LoginMapper {

    /**用户登录*/
   // @Select("select * from pay_user where userAccount = #{useraccount}")
   // PayUser userLogin(PayUser user);

    /**用户注册*/
    @Insert("INSERT INTO PAY_USER(" +
            "userId,userAccount,userPwd,paymentPwd," +
            "userName,userSex,identityCard,dateDeadine," +
            "profession,address,addressMark,securityCard," +
            "answer,createTime,userEmail,mamberProtect," +
            "upLoginTime,userIntegral,papersType,userApprove," +
            "haveBalance,power,userBalance,userIcon" +
            ") VALUES(" +
            "#{userid},#{useraccount},#{userpwd},#{paymentpwd}," +
            "#{username},#{usersex},#{identitycard},#{datedeadine}," +
            "#{profession},#{address},#{addressmark},#{securitycard}," +
            "#{answer},#{createtime},#{useremail},#{mamberprotect}," +
            "#{uplogintime},#{userintegral},#{paperstype},#{userapprove}," +
            "#{havebalance},#{power},#{userbalance},#{usericon})")
    int addUser(PayUser user);

    /**用户登录根据用户账号*/
    @Select("SELECT * FROM PAY_USER WHERE userAccount = #{useraccount}")
    PayUser userLoginByUseraccount(@Param("useraccount")String useraccount);

    /**用户登录根据用户邮箱*/
    @Select("SELECT * FROM PAY_USER WHERE userEmail = #{useremail}")
    PayUser userLoginByUseremail(@Param("useremail")String useremail);

    /**用户登录根据用户账号修改用户上次登录时间
     * @param payUser*/
    @Update("UPDATE PAY_USER SET UPLOGINTIME = #{uplogintime} WHERE userAccount = #{useraccount}")
    void updateUserLoginTimeByUseraccount(PayUser payUser);

    /**用户登录根据用户邮箱修改用户上次登录时间
     * @param payUser*/
    @Update("UPDATE PAY_USER SET UPLOGINTIME = #{uplogintime} WHERE userEmail = #{useremail}")
    void updateUserLoginTimeByUseremail(PayUser payUser);

    /**根据用户输入的银行卡号查询银行卡信息*/
    @Select("SELECT * FROM PAY_BANK WHERE bankNum = #{bankNum}")
    PayBank selBankInfoByBankNum(String bankNum);

    /**修改银行卡所绑定的用户为新注册的用户*/
    @Update("UPDATE PAY_BANK SET userId = #{userid} WHERE bankId = #{bankid}")
    void updateBankUserInfo(PayBank payBank);
}
